<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<head>
  <meta charset="UTF-8">
  <title>计数器</title>
</head>
<body>
<div id="x">
  <input type="submit" value="-" @click="sub">
  {{message}}
  <input type="submit" value="+" @click="add">
</div>
<script>
  var x=new Vue({
    el: "#x",
    data:{
      message:0
    },
    methods:{
      add:function (){
        if (this.message<10){
          this.message++;
        }else {
          alert("已经是最大啦!")
        }
      },
      sub:function (){
        if (this.message>-10){
          this.message--;
        }else {
          alert("已经是最小啦！")
        }
      }
    }
  })
</script>
</body>
</html>
